<style>
    .menu{float: left;width: 270px;margin-bottom: 19px;}
    .menu span{margin-left: 8px;}
</style>
<script charset="utf-8" src="/public/assets/script/kindeditor-4.1.10/kindeditor-min.js"></script>
<script charset="utf-8" src="/public/assets/script/kindeditor-4.1.10/lang/zh_CN.js"></script>
<script charset="utf-8" src="/public/assets/script/kindeditor-4.1.10/php/upload_json.php"></script>
<script>
    var editor;
    KindEditor.ready(function(K) {
        editor = K.create('textarea', {
                allowFileManager : true,
                afterBlur: function(){this.sync();}
        });
    }); 
</script>
<style>
select{padding: 5px;margin-right: 20px;color: #555555;}
</style>
<section class="vbox">
    <section class="scrollable padder">
        <ul class="breadcrumb no-border no-radius b-b b-light pull-in">
            <li><a href="#"><i class="fa fa-home"></i> 系统管理</a></li>
            <li><a href="#">角色管理</a></li>
            <li class="active"><a href="#">角色资料管理</a></li>
        </ul>
        <div class="m-b-md">
            <h3 class="m-b-none">角色资料管理</h3>
        </div>
        <section class="panel panel-default">
            <div class="panel-body">
            <form class="form-horizontal form-bordered form-validate" method="post" action="<?=$this->url('user/roleEdit')?>" enctype="multipart/form-data" id="hotelform" >
                <div class="form-group" style="margin-top: 10px;">
                    <label class="col-sm-2 control-label">角色名称：</label>
                    <div class="col-sm-10">
                       <input type="text" class="form-control" name="data[title]" value="<?=empty($re)?'':$re['title']?>">
                       <input type="hidden" value="<?=$id?>" name="id">
                    </div>
                </div>
                
                <div class="form-group" style="margin-top: 10px;">
                    <label class="col-sm-2 control-label">角色描述：</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" name="data[description]" value="<?=empty($re)?'':$re['description']?>">
                    </div>
                </div>
                
                <div class="form-group" style="margin-top: 10px;">
                    <label class="col-sm-2 control-label">状态：</label>
                    <div class="col-sm-10">
                        <select name="data[status]" id="status">
                            <option value="1" <?=!empty($re)&&$re['status']==1?'selected':''?>>正常</option>
                            <option value="2" <?=!empty($re)&&$re['status']==2?'selected':''?>>冻结</option>
                        </select>
                    </div>
                </div>
                
                <div class="form-group" style="margin-top: 10px;">
                    <label class="col-sm-2 control-label">菜单权限：</label>
                    <div class="col-sm-10">
                    <?php foreach ($menu as $k=>$v){ ?>
                        <div class="menu" >
                            <span style="font-weight: 600;margin-left: 0;"><?=$v['title']?></span>
                            <table>
                                <?php if(!empty($v['son'])){
                                        foreach ($v['son'] as $key=>$val){
                                    ?>
                                <tr>
                                    <td>
                                        <label style="font-weight: 500;">
                                        <input type="checkbox" <?php if(!empty($val['status'])&&$val['status']==2){ ?> checked="checked" <?php } ?> name="menu[<?=$val['menuid']?>][status]" value="2">
                                    <input type="hidden" name="menu[<?=$val['menuid']?>][title]" value="<?=$val['title']?>">
                                            <?=$val['title']?>
                                        </label>
                                    <td>
                                </tr>
                                <?php 
                                        }
                                        } ?>
                            </table>
                        </div>
                    <?php } ?>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-4 col-sm-offset-2">
                        <button type="button" onclick="window.history.go(-1);" class="btn btn-default">返 回</button>
                        <button type="submit" class="btn btn-primary show_shadefrist">保 存</button>
                    </div>
                </div>
            </form>
            </div>
        </section>
    </section>
</section>
<a href="#" class="hide nav-off-screen-block" data-toggle="class:nav-off-screen" data-target="#nav"></a>
<script type="text/javascript">
    $('#pop-up-boxes-title img').click(function(){
        $('#pop-up-boxes').css({'display':'none'});
    });
    function getTree(id){
        $.ajax({
    		type:'POST',
    		url:'<?=$this->url("user/getSon")?>',
    		data:'id='+id,
    		dataType:'json',
    		success:function(r){
                    var num = r.length;
                    var text = '';
                    for(i=0;i<num;i++){
                       text +='<tr><td>'+r[i]['title']+'</td>'+'<td><input type="hidden" name="data['+i+'][menuid]" value="'+r[i]['title']+'"><input type="hidden" name="data['+i+'][menuid]" value="'+r[i]['menuid']+'"><input type="radio" name="data['+i+'][status]" value="2">使用&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" checked name="data['+i+'][status]" value="1">冻结</td></tr>';
                    }
                    $('.divFrom').html(text);
                    $('#pop-up-boxes').css({'display':'block'});
    		},
			error:function(){
				pub_alert_error("ajax出现错误",2000);
			}
    	});
    }
    function isedit(){
        $("#edit").submit();
    }
</script>